package day03_ThreadPool.demo_network_Socket.TCP_ChatView;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server_02 {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket= new ServerSocket(10002);
            System.out.println("等待与客户端连接...");

            while (true){
                Socket socket= serverSocket.accept();
                System.out.println("连接成功");

                DataInputStream dataInputStream= new DataInputStream(socket.getInputStream());
                System.out.println(socket.getInetAddress()+" : "+dataInputStream.readUTF());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
